package com.scs.application.modules.dept.controller;

import com.scs.application.core.mvc.controller.FlowController;
import com.scs.application.modules.dept.entity.BudgetItem;
import com.scs.application.modules.dept.service.BudgetItemService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 */
@RestController
@RequestMapping("/dept/budget_item")
public class BudgetItemController extends FlowController<BudgetItemService, BudgetItem> {
//    /**
//     * 获取合适的预算年份
//     * @return
//     */
//    @RequestMapping("/getPeriodYear")
//    public RestResult getPeriodYear(@RequestParam("deptId") String deptId) {
//        int currentYear = Calendar.getInstance().get(Calendar.YEAR); //默认当前年
//        List<BudgetItem> budgetList = service.list(new QueryWrapper<BudgetItem>().eq("dept_id", deptId).orderByDesc("period_year"));
//        if(budgetList.size() > 0) {
//            BudgetItem budgetItem = budgetList.get(0);
//            if(budgetItem.getPeriodYear() == currentYear) {//已经存在，下一年
//                currentYear ++;
//            } else if (budgetItem.getPeriodYear() > currentYear) { //只能计算当年和下一年的数据，直接返回0
//                currentYear = 0;
//            }
//        }
//        return RestResult.ok("查询成功", currentYear);
//    }
}
